layui.config({
    base: '/admin/lib/layui_exts/' //配置 layui 第三方扩展组件存放的基础目录
}).extend({
    inputtags: 'inputtags/inputtags',
    croppers:'cropper/croppers',
}).use(['inputtags', 'jquery','form','croppers'], function() {
    // var inputtags = new layui.inputtags;
    var form = layui.form;
    var inputtags= layui.inputtags;
    inputtags.render({
          url:'/admin/tag/store'
        , inner: '.Ms-labe-inner' //已选主题
        , innerHidden: '.Ms-labe-innerHidden' //隐藏的输入框
        , addbtn: '.Ms-labe-addbtn' //输入框添加 按钮
        , addinput: '.Ms-labe-addinput' //输入框内容
        , backstage: '.Ms-labe-backstageBtn' //推荐标签
        , labebackstage: '.Ms-labe-backstage' //快捷选项
    });
    var croppers = layui.croppers;
    //创建一个头像上传组件
    croppers.render({
        elem: '.layui-upload-list.thumbBox.mag0.magt3'
        ,saveW:700     //保存宽度
        ,saveH:700
        ,mark:2/1    //选取比例
        ,area:'900px'  //弹窗宽度
        ,url: "/agoni/upload"  //图片上传接口返回和（layui 的upload 模块）返回的JOSN一样
        ,done: function(url){ //上传完毕回调
            $("#conver").val(url);
            $("#srcimgurl").attr('src',url);
        }
    });
});


//加载editormd
var testEditor;

$(function() {

    // You can custom @link  base url.
    editormd.urls.atLinkBase = "https://github.com/";

    testEditor = editormd("bjy-content", {
        width     : "100%",
        height    : 720,
        toc       : true,
        //atLink    : false,    // disable @link
        //emailLink : false,    // disable email address auto link
        todoList  : true,
        placeholder: '输入文章内容',
        toolbarAutoFixed: false,
        saveHTMLToTextarea : true,    // 保存 HTML 到 Textarea
        path      : '/admin/lib/editormd/lib/',
        emoji: true,
        toolbarIcons : ['undo', 'redo', 'bold', 'del', 'italic', 'quote', 'uppercase', 'h1', 'h2', 'h3', 'h4', 'h5', 'h6', 'list-ul', 'list-ol', 'hr', 'link', 'reference-link', 'image', 'code', 'code-block', 'table', 'emoji', 'html-entities', 'watch', 'preview', 'search', 'fullscreen'],
        imageUpload: true,
        imageFormats : ["jpg", "jpeg", "gif", "png", "bmp", "webp"],
        imageUploadURL : '/editormd/upload',
    });


});
var time=setInterval(function(){
    var code=$('.editormd-code-block-dialog');
    var content=$('.CodeMirror.cm-s-.CodeMirror-wrap.CodeMirror-empty');
    //var content1=$("[class='CodeMirror cm-s- CodeMirror-wrap CodeMirror-empty']");
    if(code.css('height') && content.css('height')){
        if(code.css('height')!="440px"){
            code.css('height',"440px");
            code.css('top',"0px");
            code.css('left',"10%")
        }
        if(content.css('height')!="270px"){
            content.css('height',"270px");
        }
        clearInterval(time);
    }
},1000)